import Koa from 'koa'
import koaViews from "koa-views"
import path from 'path'
import bodyParser from 'koa-bodyparser';
import cros from '@koa/cors'
import serve from 'koa-static'
import ejs from './middleware/ejs'
import router from './route'

const app = new Koa()
app
    .use(cros())
    .use(serve('./public'))
    .use(bodyParser())
    .use(koaViews(path.join(__dirname, "./views"), {
        "extension": "ejs"
    }))
    .use(router.routes())
    .use(router.allowedMethods())
    .use(ejs())

export default app
